package com.ywwxhz.plugins.tasks.widget;

import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;

import com.ywwxhz.Util.Config;
import com.ywwxhz.plugins.tasks.TaskModel;
import com.ywwxhz.service.CoreService;

public class ProcessWidget extends AppWidgetProvider {

    @Override
    public void onDeleted(Context context, int[] appWidgetIds) {
        Intent updateServer = new Intent(context, CoreService.class);
        updateServer.putExtra(Config.SERVICE_PARAM, TaskModel.MODEL);
        updateServer.putExtra(TaskModel.PARAM, TaskModel.WIDGET_DISABLE);
        context.startService(updateServer);
        super.onDeleted(context, appWidgetIds);
    }


    @Override
    public void onUpdate(Context context, AppWidgetManager appWidgetManager,
                         int[] appWidgetIds) {
        Intent updateServer = new Intent(context, CoreService.class);
        updateServer.putExtra(Config.SERVICE_PARAM, TaskModel.MODEL);
        updateServer.putExtra(TaskModel.PARAM, TaskModel.WIDGET_ENABLE);
        context.startService(updateServer);
        super.onUpdate(context, appWidgetManager, appWidgetIds);
    }
}
